home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / boot / sunprom / sun3.md / machMon.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-17  |  10.8 KB  |  382 lines

  1. /*
  2.  * machMon.h --
  3.  *
  4.  *     Structures, constants and defines for access to the sun monitor.
  5.  *     These are translated from the sun monitor header file "sunromvec.h".
  6.  *
  7.  * NOTE: The file keyboard.h in the monitor directory has all sorts of useful
  8.  *       keyboard stuff defined.  I haven't attempted to translate that file
  9.  *       because I don't need it.  If anyone wants to use it, be my guest.
  10.  *
  11.  * Copyright (C) 1985 Regents of the University of California
  12.  * All rights reserved.
  13.  *
  14.  *
  15.  * $Header: /sprite/src/boot/sunprom/sun3.md/RCS/machMon.h,v 1.1 90/09/17 10:57:28 rab Exp Locker: rab $ SPRITE (Berkeley)
  16.  */
  17.  
  18. #ifndef _MACHMON
  19. #define _MACHMON
  20.  
  21. #include <sys/types.h>
  22.  
  23. #if defined(sun4)
  24. /*
  25.  * The memory address for the PROM vector.
  26.  */
  27. #define PROM_BASE    0xffe81000
  28. #endif
  29.  
  30. #if defined(sun3) || (sun2)
  31. /*
  32.  * The memory addresses for the PROM, and the EEPROM.
  33.  * On the sun2 these addresses are actually 0x00EF??00
  34.  * but only the bottom 24 bits are looked at so these still
  35.  * work ok.
  36.  */
  37.  
  38. #define EEPROM_BASE     0x0fe04000
  39. #define PROM_BASE       0x0fef0000
  40. #endif
  41.  
  42. /*
  43.  * Where the rom vector is defined.
  44.  */
  45.  
  46. #define    romVectorPtr    ((MachMonRomVector *) PROM_BASE)
  47.  
  48.  
  49. /*
  50.  * Here is the structure of the vector table which is at the front of the boot
  51.  * rom.  The functions defined in here are explained below.
  52.  *
  53.  * NOTE: This struct has references to the structures keybuf and globram which
  54.  *       I have not translated.  If anyone needs to use these they should
  55.  *       translate these structs into Sprite format.
  56.  */
  57.  
  58. typedef struct {
  59.     char        *initSp;        /* Initial system stack ptr  
  60.                          * for hardware */
  61.     int        (*startMon)();        /* Initial PC for hardware */
  62.  
  63.     int        *diagberr;        /* Bus err handler for diags */
  64.  
  65.     /* 
  66.      * Monitor and hardware revision and identification
  67.      */
  68.  
  69.     struct MachMonBootParam **bootParam;    /* Info for bootstrapped pgm */
  70.      unsigned    *memorySize;        /* Usable memory in bytes */
  71.  
  72.     /* 
  73.      * Single-character input and output 
  74.      */
  75.  
  76.     unsigned char    (*getChar)();        /* Get char from input source */
  77.     int        (*putChar)();        /* Put char to output sink */
  78.     int        (*mayGet)();        /* Maybe get char, or -1 */
  79.     int        (*mayPut)();        /* Maybe put char, or -1 */
  80.     unsigned char    *echo;            /* Should getchar echo? */
  81.     unsigned char    *inSource;        /* Input source selector */
  82.     unsigned char    *outSink;        /* Output sink selector */
  83.  
  84.     /* 
  85.      * Keyboard input (scanned by monitor nmi routine) 
  86.      */
  87.  
  88.     int        (*getKey)();        /* Get next key if one exists */
  89.     int        (*initGetKey)();    /* Initialize get key */
  90.     unsigned int    *translation;        /* Kbd translation selector 
  91.                            (see keyboard.h in sun 
  92.                             monitor code) */
  93.     unsigned char    *keyBid;        /* Keyboard ID byte */
  94.     int        *screen_x;        /* V2: Screen x pos (R/O) */
  95.     int        *screen_y;        /* V2: Screen y pos (R/O) */
  96.     struct keybuf    *keyBuf;        /* Up/down keycode buffer */
  97.  
  98.     /*
  99.      * Monitor revision level.
  100.      */
  101.  
  102.     char        *monId;
  103.  
  104.     /* 
  105.      * Frame buffer output and terminal emulation 
  106.      */
  107.  
  108.     int        (*fbWriteChar)();    /* Write a character to FB */
  109.     int        *fbAddr;        /* Address of frame buffer */
  110.     char        **font;            /* Font table for FB */
  111.     int        (*fbWriteStr)();    /* Quickly write string to FB */
  112.  
  113.     /* 
  114.      * Reboot interface routine -- resets and reboots system.  No return. 
  115.      */
  116.  
  117.     int        (*reBoot)();        /* e.g. reBoot("xy()vmunix") */
  118.  
  119.     /* 
  120.      * Line input and parsing 
  121.      */
  122.  
  123.     unsigned char    *lineBuf;        /* The line input buffer */
  124.     unsigned char    **linePtr;        /* Cur pointer into linebuf */
  125.     int        *lineSize;        /* length of line in linebuf */
  126.     int        (*getLine)();        /* Get line from user */
  127.     unsigned char    (*getNextChar)();    /* Get next char from linebuf */
  128.     unsigned char    (*peekNextChar)();    /* Peek at next char */
  129.     int        *fbThere;        /* =1 if frame buffer there */
  130.     int        (*getNum)();        /* Grab hex num from line */
  131.  
  132.     /* 
  133.      * Print formatted output to current output sink 
  134.      */
  135.  
  136.     int        (*printf)();        /* Similar to "Kernel printf" */
  137.     int        (*printHex)();        /* Format N digits in hex */
  138.  
  139.     /*
  140.      * Led stuff 
  141.      */
  142.  
  143.     unsigned char    *leds;            /* RAM copy of LED register */
  144.     int        (*setLeds)();        /* Sets LED's and RAM copy */
  145.  
  146.     /* 
  147.      * Non-maskable interrupt  (nmi) information
  148.      */ 
  149.  
  150.     int        (*nmiAddr)();        /* Addr for level 7 vector */
  151.     int        (*abortEntry)();    /* Entry for keyboard abort */
  152.     int        *nmiClock;        /* Counts up in msec */
  153.  
  154.     /*
  155.      * Frame buffer type: see <sun/fbio.h>
  156.      */
  157.  
  158.     int        *fbType;
  159.  
  160.     /* 
  161.      * Assorted other things 
  162.      */
  163.  
  164.     unsigned    romvecVersion;        /* Version # of Romvec */ 
  165.     struct globram  *globRam;        /* monitor global variables */
  166.     Address        kbdZscc;        /* Addr of keyboard in use */
  167.  
  168.     int        *keyrInit;        /* ms before kbd repeat */
  169.     unsigned char    *keyrTick;         /* ms between repetitions */
  170.     unsigned    *memoryAvail;        /* V1: Main mem usable size */
  171.     long        *resetAddr;        /* where to jump on a reset */
  172.     long        *resetMap;        /* pgmap entry for resetaddr */
  173.                         /* Really struct pgmapent *  */
  174.     int        (*exitToMon)();        /* Exit from user program */
  175.     unsigned char    **memorybitmap;        /* V1: &{0 or &bits} */
  176.     void        (*setcxsegmap)();    /* Set seg in any context */
  177.     void        (**vector_cmd)();    /* V2: Handler for 'v' cmd */
  178.     int        dummy1z;
  179.     int        dummy2z;
  180.     int        dummy3z;
  181.     int        dummy4z;
  182. } MachMonRomVector;
  183.  
  184. /*
  185.  * Functions defined in the vector:
  186.  *
  187.  *
  188.  * getChar -- Return the next character from the input source
  189.  *
  190.  *     unsigned char getChar()
  191.  *
  192.  * putChar -- Write the given character to the output source.
  193.  *
  194.  *     void putChar(ch)
  195.  *       char ch;    
  196.  *
  197.  * mayGet -- Maybe get a character from the current input source.  Return -1 
  198.  *           if don't return a character.
  199.  *
  200.  *     int mayGet()
  201.  *    
  202.  * mayPut -- Maybe put a character to the current output source.   Return -1
  203.  *           if no character output.
  204.  *
  205.  *    int  mayPut(ch)
  206.  *        char ch;
  207.  *
  208.  * getKey -- Returns a key code (if up/down codes being returned),
  209.  *          a byte of ASCII (if that's requested),
  210.  *          NOKEY (if no key has been hit).
  211.  *
  212.  *    int getKey()
  213.  *    
  214.  * initGetKey --  Initialize things for get key.
  215.  *
  216.  *    void initGetKey()
  217.  *
  218.  * fbWriteChar -- Write a character to the frame buffer
  219.  *
  220.  *    void fwritechar(ch)
  221.  *        unsigned char ch;
  222.  *
  223.  * fbWriteStr -- Write a string to the frame buffer.
  224.  *
  225.  *       void fwritestr(addr,len)
  226.  *          register unsigned char *addr;    / * String to be written * /
  227.  *          register short len;            / * Length of string * /
  228.  *
  229.  * getLine -- read the next input line into a global buffer
  230.  *
  231.  *    getline(echop)
  232.  *          int echop;    / * 1 if should echo input, 0 if not * /
  233.  *
  234.  * getNextChar -- return the next character from the global line buffer.
  235.  *
  236.  *    unsigned char getNextChar()
  237.  *
  238.  * peekNextChar -- look at the next character in the global line buffer.
  239.  *
  240.  *    unsigned char peekNextChar()
  241.  *
  242.  * getNum -- Grab hex num from the global line buffer.
  243.  *
  244.  *    int getNum()
  245.  *
  246.  * printf -- Scaled down version of C library printf.  Only %d, %x, %s, and %c
  247.  *          are recognized.
  248.  *
  249.  * printhex -- prints rightmost <digs> hex digits of <val>
  250.  *
  251.  *      printhex(val,digs)
  252.  *          register int val;
  253.  *             register int digs;
  254.  *
  255.  * abortEntry -- Entry for keyboard abort.
  256.  *
  257.  *     abortEntry()
  258.  */
  259.  
  260. /*
  261.  * THE FOLLOWING STRUCTURES ARE TAKEN VERBATUM FROM sunromvec.h.
  262.  * The goal is to use the device driver routines in the PROM, and
  263.  * so the following structures are copied in order to retain the interface.
  264.  */
  265.  
  266. /*
  267.  * Structure set up by the boot command to pass arguments to the program that
  268.  * is booted.  (This is struct bootparam with a facelift.)
  269.  */
  270.  
  271. typedef struct MachMonBootParam {
  272.     char        *argPtr[8];    /* String arguments */
  273.     char        strings[100];    /* String table for string arguments */
  274.     char        devName[2];    /* Device name */
  275.     int        ctlrNum;    /* Controller number */
  276.     int        unitNum;    /* Unit number */
  277.     int        partNum;    /* Partition/file number */
  278.     char        *fileName;    /* File name, points into strings */
  279.     struct boottab   *bootDevice;    /* Defined below */
  280. } MachMonBootParam;
  281.  
  282. /*
  283.  * The table entry that describes a device.  It exists in the PROM; a
  284.  * pointer to it is passed in MachMonBootParam.  It can be used to locate
  285.  * PROM subroutines for opening, reading, and writing the device.
  286.  *
  287.  * When using this interface, only one device can be open at once.
  288.  */
  289.  
  290. typedef struct boottab {
  291.     char    b_dev[2];        /* The name of the device */
  292.     int    (*b_probe)();        /* probe() --> -1 or found controller 
  293.                        number */
  294.     int    (*b_boot)();        /* boot(bp) --> -1 or start address */
  295.     int    (*b_open)();        /* open(iobp) --> -1 or 0 */
  296.     int    (*b_close)();        /* close(iobp) --> -1 or 0 */
  297.     int    (*b_strategy)();    /* strategy(iobp,rw) --> -1 or 0 */
  298.     char    *b_desc;        /* Printable string describing dev */
  299.     struct b_devinfo *b_devinfo;    /* Information to configure device */
  300. } MachMonBootDevice;
  301.  
  302. enum MAPTYPES { /* Page map entry types. */
  303.   MAP_MAINMEM, 
  304.   MAP_OBIO, 
  305.   MAP_MBMEM, 
  306.   MAP_MBIO,
  307.   MAP_VME16A16D, 
  308.   MAP_VME16A32D,
  309.   MAP_VME24A16D, 
  310.   MAP_VME24A32D,
  311.   MAP_VME32A16D, 
  312.   MAP_VME32A32D
  313. };
  314.  
  315. /*
  316.  * This table gives information about the resources needed by a device.  
  317.  */
  318. typedef struct b_devinfo {
  319.   unsigned int      d_devbytes;   /* Bytes occupied by device in IO space.  */
  320.   unsigned int      d_dmabytes;   /* Bytes needed by device in DMA memory.  */
  321.   unsigned int      d_localbytes; /* Bytes needed by device for local info. */
  322.   unsigned int      d_stdcount;   /* How many standard addresses.           */
  323.   unsigned long     *d_stdaddrs;  /* The vector of standard addresses.      */
  324.   enum     MAPTYPES d_devtype;    /* What map space device is in.           */
  325.   unsigned int      d_maxiobytes; /* Size to break big I/O's into.          */
  326. } MachMonDevInfo;
  327.  
  328.  
  329. /*
  330.  * A "stand alone I/O request", taken from SunOS saio.h (struct saioreq)
  331.  * This is passed as the main argument to the PROM I/O routines
  332.  * in the MachMonBootDevice structure.
  333.  */
  334.  
  335. #if 0 
  336. typedef int daddr_t;
  337. typedef int off_t;
  338. #endif
  339.  
  340. typedef struct saioreg {
  341.     char    si_flgs;
  342.     struct boottab *si_boottab;    /* Points to boottab entry if any */
  343.     char    *si_devdata;        /* Device-specific data pointer */
  344.     int    si_ctlr;        /* Controller number or address */
  345.     int    si_unit;        /* Unit number within controller */
  346.     daddr_t    si_boff;        /* Partition number within unit */
  347.     daddr_t    si_cyloff;
  348.     off_t    si_offset;
  349.     daddr_t    si_bn;            /* Block number to R/W */
  350.     char    *si_ma;            /* Memory address to R/W */
  351.     int    si_cc;            /* Character count to R/W */
  352.     struct    saif *si_sif;        /* interface pointer (not defined yet)*/
  353.     char     *si_devaddr;        /* Points to mapped in device */
  354.     char    *si_dmaaddr;        /* Points to allocated DMA space */
  355. } MachMonIORequest;
  356.  
  357. /*
  358.  * Functions and defines to access the monitor.
  359.  */
  360.  
  361. #define Mach_MonPrintf (romVectorPtr->printf)
  362. extern    void     Mach_MonPutChar ();
  363. extern    int      Mach_MonMayPut();
  364. extern    void    Mach_MonAbort();
  365. extern    void    Mach_MonReboot();
  366.  
  367. /*
  368.  * These routines no longer work correctly with new virtual memory.
  369.  */
  370.  
  371. #define Mach_MonGetChar (romVectorPtr->getChar)
  372. #define Mach_MonGetLine (romVectorPtr->getLine)
  373. #define Mach_MonGetNextChar (romVectorPtr->getNextChar)
  374. #define Mach_MonPeekNextChar (romVectorPtr->peekNextChar)
  375.  
  376.  
  377. extern    void    Mach_MonTrap();
  378. extern    void    Mach_MonStopNmi();
  379. extern    void    Mach_MonStartNmi();
  380.  
  381. #endif /* _MACHMON */
  382.